package com.xiangban.controller;

import com.xiangban.aop.Permission;
import com.xiangban.model.Order;
import com.xiangban.model.dto.AccompanyReceiveOrderDto;
import com.xiangban.model.dto.OrderDto;
import com.xiangban.model.res.ApiResult;
import com.xiangban.service.OrderReceivingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author ly
 * @date 2021/12/8 14:05
 */
@Api("接单大厅控制器")
@RestController
@RequestMapping("api/accompany/order_receiving")
public class OrderReceivingContorller {
    @Autowired
   private OrderReceivingService orderReceivingService;
    @ApiOperation("待接单")
    @PostMapping("/await_order_receiving")

    public ApiResult<Object> awaitOrderReceiving(){
        return ApiResult.newSuccess(orderReceivingService.awaitOrderReceiving());
    }

    @ApiOperation("已接订单")
    @PostMapping("/already_order_receiving")
    @Permission
    public ApiResult<Object> alreadyOrderReceiving(){
        return ApiResult.newSuccess(orderReceivingService.alreadyOrderReceiving());
    }

    @ApiOperation("确认订单")
    @PostMapping("order_ok")
    @Permission
    public ApiResult<Object> orderOk(@RequestBody Order order){//订单编号给我 然后改变状态  accompany_status 0 未答复 1 接单2 拒绝

        return ApiResult.newSuccess(orderReceivingService.orderOk(order));
    }

    @ApiOperation("订单详情")
    @PostMapping("order_details")
    @Permission
    public ApiResult<Object> orderDetails(@RequestBody Order order) throws Exception {
        return ApiResult.newSuccess(orderReceivingService.orderDetails(order));
    }
   @ApiOperation("提交材料")
   @PostMapping("submit_data")
   @Permission
    public ApiResult<Object> submitData(@RequestBody AccompanyReceiveOrderDto accompanyReceiveOrder){
        orderReceivingService.submitData(accompanyReceiveOrder);
        return ApiResult.newSuccess("ok");

   }
    @ApiOperation("服务结束")
    @PostMapping("service_over")
    @Permission
    public ApiResult<Object> serviceOver(@RequestBody AccompanyReceiveOrderDto accompanyReceiveOrder){
        orderReceivingService.serviceOver(accompanyReceiveOrder);
        return ApiResult.newSuccess("ok");
   }
    @ApiOperation("我的订单")
    @PostMapping("my_order")
    @Permission
    public ApiResult<Object> myOrder(@RequestBody Order order){//陪诊iid

        return ApiResult.newSuccess(orderReceivingService.myOrder(order));
   }

    @ApiOperation("联系用户")
    @PostMapping("user_phone")
    @Permission
    public ApiResult<Object> userPhone(@RequestBody  Order order){//订单编号
        return ApiResult.newSuccess(orderReceivingService.userPhone(order));
   }

    @ApiOperation("用户评价")
    @PostMapping("user_evaluate")
    @Permission
    public ApiResult<Object> userEvaluate(@RequestBody Order order){//陪诊id
        return ApiResult.newSuccess(orderReceivingService.userEvaluate(order));
   }
    @ApiOperation("生成加密数据")
    @PostMapping("QR_code")
    @Permission
    public ApiResult<Object> QRCode() throws Exception {
        return  ApiResult.newSuccess(orderReceivingService.QRCode());
    }
    @ApiOperation("解密数据")
    @PostMapping("decode")
    @Permission
    public ApiResult<Object> decode(@RequestBody Map<String,String> decode) throws Exception {
        orderReceivingService.decode(decode.get("decode"));
        return  ApiResult.newSuccess("ok");
    }

    @ApiOperation("接单状态")
    @PostMapping("order_receiving_status")
    @Permission
    public ApiResult<Object> orderReceivingStatus(@RequestBody OrderDto orderDto){//orderNo   status 1   2  经纬度

        return ApiResult.newSuccess(orderReceivingService.orderReceivingStatus(orderDto));
    }


}
